package com.huawei.appgallery.forum.option.comment.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import com.huawei.appgallery.foundation.ui.framework.widget.MaskImageView;
import o.bqx;
import o.byc$g;
import o.dky.a;

public class RoundCornerImageView extends MaskImageView {
    private boolean ʼ;
    private int ʽ;
    private int ˊ;
    private int ˋ;
    private int ˏ;

    public RoundCornerImageView(Context context) {
        this(context, null);
    }

    public RoundCornerImageView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public RoundCornerImageView(Context context, AttributeSet attributeSet, int i) {
        int i2 = 0;
        super(context, attributeSet, i);
        this.ʼ = true;
        if (attributeSet != null) {
            try {
                int dimensionPixelSize;
                TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, byc$g.ㆍॱ, i, 0);
                if (obtainStyledAttributes.hasValue(byc$g.ꓸॱ)) {
                    i2 = obtainStyledAttributes.getDimensionPixelSize(byc$g.ꓸॱ, 0);
                }
                this.ˊ = obtainStyledAttributes.hasValue(byc$g.ⁱ) ? obtainStyledAttributes.getDimensionPixelSize(byc$g.ⁱ, i2) : i2;
                if (obtainStyledAttributes.hasValue(byc$g.ꜟॱ)) {
                    dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(byc$g.ꜟॱ, i2);
                } else {
                    dimensionPixelSize = i2;
                }
                this.ˏ = dimensionPixelSize;
                if (obtainStyledAttributes.hasValue(byc$g.ꜝ)) {
                    dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(byc$g.ꜝ, i2);
                } else {
                    dimensionPixelSize = i2;
                }
                this.ˋ = dimensionPixelSize;
                if (obtainStyledAttributes.hasValue(byc$g.ꞌॱ)) {
                    i2 = obtainStyledAttributes.getDimensionPixelSize(byc$g.ꞌॱ, i2);
                }
                this.ʽ = i2;
                this.ʼ = obtainStyledAttributes.hasValue(byc$g.ﹳॱ) ? obtainStyledAttributes.getBoolean(byc$g.ﹳॱ, this.ʼ) : this.ʼ;
                obtainStyledAttributes.recycle();
            } catch (RuntimeException e) {
                bqx.ॱ("RoundImageView", "RoundImageView init(AttributeSet attrs) ");
            }
        }
    }

    public void ˎ() {
        if (this.ʼ) {
            this.ॱ = getResources().getDrawable(a.ˋˊ);
        } else {
            this.ॱ = null;
        }
    }

    protected void onDraw(Canvas canvas) {
        ˋ(canvas, getWidth(), getHeight());
        super.onDraw(canvas);
    }

    private void ˋ(Canvas canvas, int i, int i2) {
        if (Math.min(i, i2) > Math.max(Math.max(this.ˊ, this.ˋ), Math.max(this.ˏ, this.ʽ))) {
            Path path = new Path();
            path.moveTo((float) this.ˊ, 0.0f);
            path.lineTo((float) (i - this.ˏ), 0.0f);
            path.quadTo((float) i, 0.0f, (float) i, (float) this.ˏ);
            path.lineTo((float) i, (float) (i2 - this.ʽ));
            path.quadTo((float) i, (float) i2, (float) (i - this.ʽ), (float) i2);
            path.lineTo((float) this.ˋ, (float) i2);
            path.quadTo(0.0f, (float) i2, 0.0f, (float) (i2 - this.ˋ));
            path.lineTo(0.0f, (float) this.ˊ);
            path.quadTo(0.0f, 0.0f, (float) this.ˊ, 0.0f);
            canvas.clipPath(path);
        }
    }
}
